﻿using Domain.Flow;
using MediatR;
using U.B.ErrorCode;
using U.B.ReadApi.Command.Raddit.BW;
using U.B.Repistory;

namespace U.B.ReadApi.CommandHander.Raddit.BWHA
{
    public class GetFirmCommandHander : IRequestHandler<GetFirmCommand, ApiResult<Firm>>
    {
        public readonly IRepistory<Firm> _firmRepistory;

        public GetFirmCommandHander(IRepistory<Firm> firmRepistory)
        {
            _firmRepistory = firmRepistory;
        }
        /// <summary>
        /// 企业反填
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public Task<ApiResult<Firm>> Handle(GetFirmCommand request, CancellationToken cancellationToken)
        {
           ApiResult<Firm>  apiResult = new ApiResult<Firm>();
            var result = _firmRepistory.GetAll().FirstOrDefault(x=>x.BatchId == request.BatchId);
            apiResult.Message = Renum.显示成功.ToString();
            apiResult.Data = result;
            apiResult.code = Renum.显示成功;
            return Task.FromResult(apiResult);
        }
    }
}
